package main

import (
	"net/http"
	"io/ioutil"
	"bytes"
	"fmt"
	"time"
    "encoding/json"
)

func main(){

	client := &http.Client{
		Transport: &http.Transport{
		},
	}

    data := map[string]interface{}{
        "metric": "cpu_test",
        "tags": "host=1.1.1.1",
        "timestamp": "1367777864",
        "value": 2,
    }
    args ,_ :=json.Marshal(data)

	for {
		req, err := http.NewRequest("POST", "http://10.20.0.10:8433/eagleeye-transfer/push", bytes.NewBuffer([]byte(args)))

		if err != nil {
			return
			// handle error

		}

		resp, err := client.Do(req)

		if err != nil {

			// handle error
			fmt.Println("1111")
			return
		}
		defer resp.Body.Close()

		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return
		}

		fmt.Println(string(body))
		time.Sleep(10*time.Millisecond)
	}
}
